package com.ruoyi.deeplearn.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.deeplearn.domain.DeepTagGroup;
import com.ruoyi.deeplearn.service.IDeepTagGroupService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 标签组Controller
 *
 * @author rww
 * @date 2022-12-10
 */
@RestController
@RequestMapping("/deeplearn/taggroup")
public class DeepTagGroupController extends BaseController
{
    @Autowired
    private IDeepTagGroupService deepTagGroupService;

    /**
     * 查询标签组列表
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:taggroup:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeepTagGroup deepTagGroup)
    {
        startPage();
        List<DeepTagGroup> list = deepTagGroupService.selectDeepTagGroupList(deepTagGroup);
        return getDataTable(list);
    }

//    @PreAuthorize("@ss.hasPermi('deeplearn:taggroup:list')")
    @GetMapping("/list/all")
    public AjaxResult listAll(DeepTagGroup deepTagGroup)
    {
        List<DeepTagGroup> list = deepTagGroupService.selectDeepTagGroupList(deepTagGroup);
        return success(list);
    }

    /**
     * 导出标签组列表
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:taggroup:export')")
    @Log(title = "标签组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeepTagGroup deepTagGroup)
    {
        List<DeepTagGroup> list = deepTagGroupService.selectDeepTagGroupList(deepTagGroup);
        ExcelUtil<DeepTagGroup> util = new ExcelUtil<DeepTagGroup>(DeepTagGroup.class);
        util.exportExcel(response, list, "标签组数据");
    }

    /**
     * 获取标签组详细信息
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:taggroup:query')")
    @GetMapping(value = "/{groupId}")
    public AjaxResult getInfo(@PathVariable("groupId") Long groupId)
    {
        return success(deepTagGroupService.selectDeepTagGroupByGroupId(groupId));
    }

    /**
     * 新增标签组
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:taggroup:add')")
    @Log(title = "标签组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeepTagGroup deepTagGroup)
    {
        return toAjax(deepTagGroupService.insertDeepTagGroup(deepTagGroup));
    }

    /**
     * 修改标签组
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:taggroup:edit')")
    @Log(title = "标签组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeepTagGroup deepTagGroup)
    {
        return toAjax(deepTagGroupService.updateDeepTagGroup(deepTagGroup));
    }

    /**
     * 删除标签组
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:taggroup:remove')")
    @Log(title = "标签组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{groupIds}")
    public AjaxResult remove(@PathVariable Long[] groupIds)
    {
        return toAjax(deepTagGroupService.deleteDeepTagGroupByGroupIds(groupIds));
    }
}
